package cn.starrysky108.simpleerp.core.exception;

import cn.starrysky108.simpleerp.core.enums.ResultCodeEnum;
import io.micrometer.core.lang.Nullable;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author Carl Lee
 * entity未找到异常
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class ApiException extends RuntimeException {
    private ResultCodeEnum codeEnum;
    /**
     * 向前端发送的数据
     */
    private Object data;

    public ApiException(String message) {
        super(message);
    }

    public ApiException(ResultCodeEnum codeEnum) {
        super(codeEnum.getMessage());
        this.codeEnum = codeEnum;
    }

    public ApiException(ResultCodeEnum codeEnum, @Nullable Object data) {
        super(codeEnum.getMessage());
        this.codeEnum = codeEnum;
        this.data = data;
    }

    public ApiException(String message, Throwable cause) {
        super(message, cause);
    }

    public ApiException(ResultCodeEnum codeEnum, Throwable cause, @Nullable Object data) {
        super(codeEnum.getMessage(), cause);
        this.codeEnum = codeEnum;
        this.data = data;
    }


}
